/*
 Navicat Premium Data Transfer

 Source Server         : sqlserver
 Source Server Type    : SQL Server
 Source Server Version : 10501600 (10.50.1600)
 Source Host           : localhost:1433
 Source Catalog        : LightData
 Source Schema         : dbo

 Target Server Type    : SQL Server
 Target Server Version : 10501600 (10.50.1600)
 File Encoding         : 65001

 Date: 15/07/2024 15:36:42
*/


-- ----------------------------
-- Table structure for B_Area
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Area]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Area]
GO

CREATE TABLE [dbo].[B_Area] (
  [ID] int  NOT NULL,
  [AreaCode] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [AreaName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[B_Area] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_Building
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Building]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Building]
GO

CREATE TABLE [dbo].[B_Building] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [AreaID] int  NOT NULL,
  [Type] int  NULL,
  [Quality] int  NULL,
  [BuildingName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [Address] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [PropertyUnit] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [PropertyUnitContact] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [PropertyUnitContactPhone] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [OwnerUnit] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [OwnerUnitContact] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [OwnerUnitContactPhone] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [CreatedDate] datetime  NULL,
  [CreatdUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [UpdatedDate] datetime  NULL,
  [UpdatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [DeleteFlag] int  NULL
)
GO

ALTER TABLE [dbo].[B_Building] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_Company
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Company]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Company]
GO

CREATE TABLE [dbo].[B_Company] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [CompanyName] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [FullName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [CompanyType] int  NULL,
  [Address] nvarchar(100) COLLATE Chinese_PRC_CI_AS  NULL,
  [Contacts] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [ContactPhone] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[B_Company] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_Construct
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Construct]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Construct]
GO

CREATE TABLE [dbo].[B_Construct] (
  [ID] int  NOT NULL,
  [ConstructCode] nvarchar(30) COLLATE Chinese_PRC_CI_AS  NULL,
  [ConstructName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [ConstructDate] date  NULL,
  [FinishDate] date  NULL
)
GO

ALTER TABLE [dbo].[B_Construct] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_District
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_District]') AND type IN ('U'))
	DROP TABLE [dbo].[B_District]
GO

CREATE TABLE [dbo].[B_District] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [DistrictCode] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [DistrictName] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [DistrictType] int  NULL
)
GO

ALTER TABLE [dbo].[B_District] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_Group
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Group]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Group]
GO

CREATE TABLE [dbo].[B_Group] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [GroupName] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [SysID] int  NULL,
  [CreatedDate] datetime  NULL,
  [CreatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [UpdatedDate] datetime  NULL,
  [UpdatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [DeleteFlag] int  NULL,
  [GroupID] int  NULL,
  [DistrictID] int  NULL
)
GO

ALTER TABLE [dbo].[B_Group] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_GroupSatation
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_GroupSatation]') AND type IN ('U'))
	DROP TABLE [dbo].[B_GroupSatation]
GO

CREATE TABLE [dbo].[B_GroupSatation] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [GroupID] int  NULL,
  [StationID] int  NULL
)
GO

ALTER TABLE [dbo].[B_GroupSatation] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_Interface
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Interface]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Interface]
GO

CREATE TABLE [dbo].[B_Interface] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [Type] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [URL] nvarchar(250) COLLATE Chinese_PRC_CI_AS  NULL,
  [CreatedDate] datetime  NULL,
  [CreatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [UpdatedDate] datetime  NULL,
  [UpdatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [DeleteFalg] int  NULL
)
GO

ALTER TABLE [dbo].[B_Interface] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_Light
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Light]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Light]
GO

CREATE TABLE [dbo].[B_Light] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [StationID] int  NULL,
  [ClassName] nvarchar(30) COLLATE Chinese_PRC_CI_AS  NULL,
  [TypeName] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [ModelNmae] nvarchar(30) COLLATE Chinese_PRC_CI_AS  NULL,
  [Power] numeric(10,2)  NULL
)
GO

ALTER TABLE [dbo].[B_Light] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_Location
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Location]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Location]
GO

CREATE TABLE [dbo].[B_Location] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [Description] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [RelativePath] nvarchar(250) COLLATE Chinese_PRC_CI_AS  NULL,
  [FileName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[B_Location] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_Meter
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Meter]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Meter]
GO

CREATE TABLE [dbo].[B_Meter] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [MeterNumber] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [StationID] int  NULL,
  [CommID] int  NULL,
  [MeterType] nvarchar(30) COLLATE Chinese_PRC_CI_AS  NULL,
  [LocationInformation] int  NULL
)
GO

ALTER TABLE [dbo].[B_Meter] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_Permission
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Permission]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Permission]
GO

CREATE TABLE [dbo].[B_Permission] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [PermissionID] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [PermissionName] nvarchar(30) COLLATE Chinese_PRC_CI_AS  NULL,
  [ModuleName] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[B_Permission] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_Role
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Role]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Role]
GO

CREATE TABLE [dbo].[B_Role] (
  [id] int  IDENTITY(1,1) NOT NULL,
  [roldId] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [roleName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NOT NULL
)
GO

ALTER TABLE [dbo].[B_Role] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_RolePermission
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_RolePermission]') AND type IN ('U'))
	DROP TABLE [dbo].[B_RolePermission]
GO

CREATE TABLE [dbo].[B_RolePermission] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [RoldID] int  NULL,
  [PermissionID] int  NULL
)
GO

ALTER TABLE [dbo].[B_RolePermission] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_StationInfo
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_StationInfo]') AND type IN ('U'))
	DROP TABLE [dbo].[B_StationInfo]
GO

CREATE TABLE [dbo].[B_StationInfo] (
  [ID] int  NOT NULL,
  [UpdateTime] datetime  NULL,
  [State] int  NULL,
  [SysId] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [CommID] int  NULL,
  [StationCode] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [StationName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [OPCAddress] nvarchar(30) COLLATE Chinese_PRC_CI_AS  NULL,
  [AreaID] int  NULL,
  [DistrictID] int  NULL,
  [LightID] int  NULL,
  [IP] nvarchar(30) COLLATE Chinese_PRC_CI_AS  NULL,
  [InvestmentMode] int  NULL,
  [ConstructID] int  NULL,
  [BuildingID] int  NULL,
  [LocationInformation] nvarchar(100) COLLATE Chinese_PRC_CI_AS  NULL,
  [ScopeOfManagement] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [MaintenanceUnit] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [ControlUnit] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [ProjectCode] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [SubsidizedUnitPrice] numeric(10,2)  NULL,
  [ElectricRatio] numeric(10,2)  NULL,
  [totalPower] numeric(10,2)  NULL,
  [totalLamps] int  NULL,
  [pointPhoto] nvarchar(250) COLLATE Chinese_PRC_CI_AS  NULL,
  [pointNightPhoto] nvarchar(250) COLLATE Chinese_PRC_CI_AS  NULL,
  [lng] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [lat] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [CreatedDate] datetime  NULL,
  [CreatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [UpdatedDate] datetime  NULL,
  [UpdatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [DeleteFlag] int  NULL,
  [circuitNum] int  NULL,
  [DMXNum] int  NULL,
  [energyMeter] int  NULL,
  [sysName] nvarchar(100) COLLATE Chinese_PRC_CI_AS  NULL,
  [address] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[B_StationInfo] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_System
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_System]') AND type IN ('U'))
	DROP TABLE [dbo].[B_System]
GO

CREATE TABLE [dbo].[B_System] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [SysId] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [SysName] nvarchar(30) COLLATE Chinese_PRC_CI_AS  NULL,
  [Password] nvarchar(100) COLLATE Chinese_PRC_CI_AS  NULL,
  [Token] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [ExpirationDate] datetime  NULL,
  [CreatedDate] datetime  NULL,
  [CreatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [UpdatedDate] datetime  NULL,
  [UpdatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [DeleteFlag] int  NULL
)
GO

ALTER TABLE [dbo].[B_System] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for B_Users
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[B_Users]') AND type IN ('U'))
	DROP TABLE [dbo].[B_Users]
GO

CREATE TABLE [dbo].[B_Users] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [UserName] nvarchar(30) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [CompanyID] int  NULL,
  [Password] nvarchar(100) COLLATE Chinese_PRC_CI_AS  NULL,
  [Token] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [LoginTime] datetime  NULL,
  [ExpireTime] datetime  NULL,
  [avatar] nvarchar(100) COLLATE Chinese_PRC_CI_AS  NULL,
  [roleID] int  NULL,
  [Phone] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [CreatedDate] datetime  NULL,
  [CreatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [UpdatedDate] datetime  NULL,
  [UpdatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [DeleteFlag] int DEFAULT 0 NULL
)
GO

ALTER TABLE [dbo].[B_Users] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for S_Data1Day
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[S_Data1Day]') AND type IN ('U'))
	DROP TABLE [dbo].[S_Data1Day]
GO

CREATE TABLE [dbo].[S_Data1Day] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [SysID] int  NULL,
  [StationCode] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [StationID] int  NULL,
  [CommID] int  NULL,
  [staDate] date  NULL,
  [DI] int  NULL,
  [AIData1] decimal(18,2)  NULL,
  [AIData2] decimal(18,2)  NULL,
  [ElectricQuantity] decimal(18,2)  NULL,
  [OpenMinute] int  NULL,
  [CreatedTime] datetime  NULL
)
GO

ALTER TABLE [dbo].[S_Data1Day] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for S_Data1Hour
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[S_Data1Hour]') AND type IN ('U'))
	DROP TABLE [dbo].[S_Data1Hour]
GO

CREATE TABLE [dbo].[S_Data1Hour] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [StationID] int  NULL,
  [StationCode] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [SysID] int  NULL,
  [CommID] int  NULL,
  [staDate] date  NULL,
  [staHour] int  NULL,
  [DI] int  NULL,
  [AIData1] decimal(18,2)  NULL,
  [AIData2] decimal(18,2)  NULL,
  [ElectricQuantity] decimal(18,2)  NULL,
  [OpenMinute] int  NULL,
  [CreatedTime] datetime  NULL
)
GO

ALTER TABLE [dbo].[S_Data1Hour] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for T_Data
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[T_Data]') AND type IN ('U'))
	DROP TABLE [dbo].[T_Data]
GO

CREATE TABLE [dbo].[T_Data] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [StationID] int  NULL,
  [SysId] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [StationCode] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [CommID] int  NULL,
  [MeterNumber] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [Current01] decimal(18,2)  NULL,
  [Current02] decimal(18,2)  NULL,
  [Current03] decimal(18,2)  NULL,
  [Voltage01] decimal(18,2)  NULL,
  [Voltage02] decimal(18,2)  NULL,
  [Voltage03] decimal(18,2)  NULL,
  [DI] int  NULL,
  [Mask] int  NULL,
  [staDate] datetime  NULL,
  [AIData] decimal(18,2)  NULL,
  [autoRemote] int  NULL,
  [RemoteManual] int  NULL,
  [GPSStatus] int  NULL,
  [PLCStatus] int  NULL,
  [programStatus] int  NULL,
  [staState] int  NULL,
  [comState] int  NULL
)
GO

ALTER TABLE [dbo].[T_Data] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'DI15',
'SCHEMA', N'dbo',
'TABLE', N'T_Data',
'COLUMN', N'autoRemote'
GO

EXEC sp_addextendedproperty
'MS_Description', N'DI0',
'SCHEMA', N'dbo',
'TABLE', N'T_Data',
'COLUMN', N'RemoteManual'
GO


-- ----------------------------
-- Table structure for T_GroupInfo
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[T_GroupInfo]') AND type IN ('U'))
	DROP TABLE [dbo].[T_GroupInfo]
GO

CREATE TABLE [dbo].[T_GroupInfo] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [UpdateTime] datetime  NULL,
  [SysId] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [SysName] nvarchar(100) COLLATE Chinese_PRC_CI_AS  NULL,
  [DistrictID] int  NULL,
  [GroupID] int  NULL,
  [GroupName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [StationNum] int  NULL,
  [StationIdList] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[T_GroupInfo] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for T_GroupPlan
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[T_GroupPlan]') AND type IN ('U'))
	DROP TABLE [dbo].[T_GroupPlan]
GO

CREATE TABLE [dbo].[T_GroupPlan] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [SysID] int  NULL,
  [GroupID] int  NULL,
  [OpenDate] date  NULL,
  [StartTime] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [EndTime] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [lightingMode] int  NULL
)
GO

ALTER TABLE [dbo].[T_GroupPlan] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'当日开关灯模式，0 不使用，1 
日常，2 节假日，3 重大节假日',
'SCHEMA', N'dbo',
'TABLE', N'T_GroupPlan',
'COLUMN', N'lightingMode'
GO


-- ----------------------------
-- Table structure for T_Log
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[T_Log]') AND type IN ('U'))
	DROP TABLE [dbo].[T_Log]
GO

CREATE TABLE [dbo].[T_Log] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [ModuleName] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [LogDate] datetime  NULL,
  [LogType] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [ResultName] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [Description] nvarchar(500) COLLATE Chinese_PRC_CI_AS  NULL,
  [CreatedUser] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [CreatedTime] datetime  NULL
)
GO

ALTER TABLE [dbo].[T_Log] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for T_Plan
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[T_Plan]') AND type IN ('U'))
	DROP TABLE [dbo].[T_Plan]
GO

CREATE TABLE [dbo].[T_Plan] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [SysID] int  NULL,
  [StationCode] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [StationID] int  NULL,
  [OpenDate] date  NULL,
  [StartTime] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [EndTime] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[T_Plan] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for T_RealTimeData
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[T_RealTimeData]') AND type IN ('U'))
	DROP TABLE [dbo].[T_RealTimeData]
GO

CREATE TABLE [dbo].[T_RealTimeData] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [StationID] int  NULL,
  [SysID] int  NULL,
  [StationCode] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [CommID] int  NULL,
  [AreaID] int  NULL,
  [DistrictID] int  NULL,
  [MeterNumber] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [State] int  NULL,
  [Current01] decimal(18,2)  NULL,
  [Current02] decimal(18,2)  NULL,
  [Current03] decimal(18,2)  NULL,
  [Voltage01] decimal(18,2)  NULL,
  [Voltage02] decimal(18,2)  NULL,
  [Voltage03] decimal(18,2)  NULL,
  [DI] int  NULL,
  [Mask] int  NULL,
  [staDate] datetime  NULL,
  [AIData] decimal(18,2)  NULL,
  [autoRemote] int  NULL,
  [RemoteManual] int  NULL,
  [GPSStatus] int  NULL,
  [PLSStatus] int  NULL,
  [programStatus] int  NULL,
  [staState] int  NULL,
  [comState] int  NULL,
  [LastSettlement] decimal(18,2)  NULL,
  [LastSettlementTime] datetime  NULL,
  [CreatedDate] datetime  NULL,
  [UpdatedDate] datetime  NULL
)
GO

ALTER TABLE [dbo].[T_RealTimeData] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for T_StationLightingPlan
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[T_StationLightingPlan]') AND type IN ('U'))
	DROP TABLE [dbo].[T_StationLightingPlan]
GO

CREATE TABLE [dbo].[T_StationLightingPlan] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [UpdateTime] datetime  NULL,
  [SysId] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [SysName] nvarchar(100) COLLATE Chinese_PRC_CI_AS  NULL,
  [DistrictID] int  NULL,
  [StationID] int  NULL,
  [StationName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [GroupID] int  NULL,
  [TrunonTime] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [TurnoffTime] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [LightingMode] int  NULL
)
GO

ALTER TABLE [dbo].[T_StationLightingPlan] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Table structure for T_StationStatus
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[T_StationStatus]') AND type IN ('U'))
	DROP TABLE [dbo].[T_StationStatus]
GO

CREATE TABLE [dbo].[T_StationStatus] (
  [ID] int  IDENTITY(1,1) NOT NULL,
  [UpdateTime] datetime  NULL,
  [SysId] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [SysName] nvarchar(100) COLLATE Chinese_PRC_CI_AS  NULL,
  [DistrictID] int  NULL,
  [StationID] int  NULL,
  [StationName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [GroupID] int  NULL,
  [InputDis] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [CurrentPhaseA] decimal(18,2)  NULL,
  [CurrentPhaseB] decimal(18,2)  NULL,
  [CurrentPhaseC] decimal(18,2)  NULL,
  [VoltagePhaseA] decimal(18,2)  NULL,
  [VoltagePhaseB] decimal(18,2)  NULL,
  [VoltagePhaseC] decimal(18,2)  NULL,
  [ActivePower] decimal(18,2)  NULL,
  [ElecConsumption] int  NULL
)
GO

ALTER TABLE [dbo].[T_StationStatus] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Auto increment value for B_Building
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_Building]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for B_Company
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_Company]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for B_District
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_District]', RESEED, 1)
GO


-- ----------------------------
-- Primary Key structure for table B_District
-- ----------------------------
ALTER TABLE [dbo].[B_District] ADD CONSTRAINT [PK__B_Distri__3214EC273D5E1FD2] PRIMARY KEY CLUSTERED ([ID])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for B_Group
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_Group]', RESEED, 7)
GO


-- ----------------------------
-- Primary Key structure for table B_Group
-- ----------------------------
ALTER TABLE [dbo].[B_Group] ADD CONSTRAINT [PK__B_Group__3214EC27403A8C7D] PRIMARY KEY CLUSTERED ([ID])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for B_GroupSatation
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_GroupSatation]', RESEED, 3)
GO


-- ----------------------------
-- Primary Key structure for table B_GroupSatation
-- ----------------------------
ALTER TABLE [dbo].[B_GroupSatation] ADD CONSTRAINT [PK__B_GroupS__3214EC274316F928] PRIMARY KEY CLUSTERED ([ID])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for B_Interface
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_Interface]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for B_Light
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_Light]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for B_Location
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_Location]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for B_Meter
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_Meter]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for B_Permission
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_Permission]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for B_Role
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_Role]', RESEED, 1)
GO


-- ----------------------------
-- Primary Key structure for table B_Role
-- ----------------------------
ALTER TABLE [dbo].[B_Role] ADD CONSTRAINT [PK_B_Role] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for B_RolePermission
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_RolePermission]', RESEED, 1)
GO


-- ----------------------------
-- Primary Key structure for table B_StationInfo
-- ----------------------------
ALTER TABLE [dbo].[B_StationInfo] ADD CONSTRAINT [PK__B_Statio__3214EC273A81B327] PRIMARY KEY CLUSTERED ([ID])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for B_System
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_System]', RESEED, 6)
GO


-- ----------------------------
-- Auto increment value for B_Users
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[B_Users]', RESEED, 1)
GO


-- ----------------------------
-- Primary Key structure for table B_Users
-- ----------------------------
ALTER TABLE [dbo].[B_Users] ADD CONSTRAINT [PK_B_Users] PRIMARY KEY CLUSTERED ([ID])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for S_Data1Day
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[S_Data1Day]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for S_Data1Hour
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[S_Data1Hour]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for T_Data
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[T_Data]', RESEED, 1)
GO


-- ----------------------------
-- Primary Key structure for table T_Data
-- ----------------------------
ALTER TABLE [dbo].[T_Data] ADD CONSTRAINT [PK__T_Data__3214EC2745F365D3] PRIMARY KEY CLUSTERED ([ID])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for T_GroupInfo
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[T_GroupInfo]', RESEED, 1)
GO


-- ----------------------------
-- Primary Key structure for table T_GroupInfo
-- ----------------------------
ALTER TABLE [dbo].[T_GroupInfo] ADD CONSTRAINT [PK__T_GroupI__3214EC2748CFD27E] PRIMARY KEY CLUSTERED ([ID])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for T_GroupPlan
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[T_GroupPlan]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for T_Log
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[T_Log]', RESEED, 1)
GO


-- ----------------------------
-- Primary Key structure for table T_Log
-- ----------------------------
ALTER TABLE [dbo].[T_Log] ADD CONSTRAINT [PK_T_Log] PRIMARY KEY CLUSTERED ([ID])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for T_Plan
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[T_Plan]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for T_RealTimeData
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[T_RealTimeData]', RESEED, 1)
GO


-- ----------------------------
-- Auto increment value for T_StationLightingPlan
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[T_StationLightingPlan]', RESEED, 1)
GO


-- ----------------------------
-- Primary Key structure for table T_StationLightingPlan
-- ----------------------------
ALTER TABLE [dbo].[T_StationLightingPlan] ADD CONSTRAINT [PK__T_Statio__3214EC274BAC3F29] PRIMARY KEY CLUSTERED ([ID])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for T_StationStatus
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[T_StationStatus]', RESEED, 2)
GO


-- ----------------------------
-- Primary Key structure for table T_StationStatus
-- ----------------------------
ALTER TABLE [dbo].[T_StationStatus] ADD CONSTRAINT [PK__T_Statio__3214EC274E88ABD4] PRIMARY KEY CLUSTERED ([ID])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO

